package org.devocean.groupbuying.service.impl;

import org.devocean.groupbuying.dao.LinkStatDAO;
import org.devocean.groupbuying.domain.LinkStat;
import org.devocean.groupbuying.service.LinkStatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class LinkStatServiceImpl implements LinkStatService {

	@Autowired
	private LinkStatDAO linkStatDAO;

	@Transactional(readOnly = true)
	public LinkStat getLinkStatById(Integer id) {

		return linkStatDAO.findLinkStatById(id);
	}

	@Transactional
	public LinkStat addOrUpdateLinkStat(LinkStat linkStat) {
		if (linkStat.getLinkStatID() == null)
			return linkStatDAO.saveLinkStat(linkStat);
		else {
			return linkStatDAO.updateLinkStat(linkStat);
		}
	}

	@Transactional
	public void removeLinkStat(Integer id) {
		linkStatDAO.deleteLinkStat(id);

	}

	public long countLinkStats() {
		return linkStatDAO.countLinkStat();
	}



}
